package com.googlecode.horncomb.core.paged;

public abstract class PagedSizeUtil {

	public static int caclStartIndex(int pageSize, int page) {
		return (pageSize * (page - 1));
	}

	public static int caclEndIndexByStart(int startIndex, int pageSize,
			int count) {
		int endIndex = startIndex + pageSize;
		return (endIndex > (count - 1) ? (count - 1) : endIndex);
	}

	public static int caclEndIndexByPage(int pageSize, int page, int count) {
		int endIndex = pageSize * page;
		return (endIndex > count ? count : endIndex) - 1;
	}

	public static int caclPageSize(int startIndex, int endIndex) {
		return endIndex - startIndex + 1;
	}
}
